import 'package:flutter/services.dart';

class ChannelUtils {
  static const _channelName = "com.hlj.smartpad.android/launcher";
  static const SETTING = "android.settings.SETTINGS";

  static const LAUNCHER = "android.intent.action.MAIN";

  static MethodChannel? _batteryChannel;

  static const _pkgNameList = [
    "com.hlj.smartpad.android.ten",
    "com.bro.device_auth"
  ];

  static Future<dynamic> getAppInfo() async {
    return invoke("app_info", arguments: _pkgNameList);
  }

  static Future<dynamic> getStatus() async {
    return invoke("get_status");
  }

  static Future<dynamic> setStatus(bool status) async {
    return invoke("set_status", arguments: status);
  }

  static Future<dynamic> evokeApp(String? argument) async {
    return invoke("evoke_app", arguments: argument);
  }

  static Future<dynamic> jumpPage(String? argument) async {
    return invoke("jump_page", arguments: argument);
  }

  static Future<dynamic> invoke(String method, {dynamic arguments}) async {
    return await channelInstance()?.invokeMethod(method, arguments);
  }

  static MethodChannel? channelInstance() {
    _batteryChannel ??= const MethodChannel(_channelName);
    return _batteryChannel;
  }
}
